package com.avic.common.convertor;


import com.avic.common.constant.AppConstant;
import com.avic.controller.info.UavResourceListInfo;
import com.avic.dal.model.UavResource;
import org.apache.commons.lang3.StringUtils;

import java.util.ArrayList;
import java.util.List;

/**
 * 车辆资源对象转换器
 */
public class UavResourceConvertor {


    public static List<UavResourceListInfo> uavResourceListVOToUavResourceListInfo(List<UavResource> uavResources) {
        if (null != uavResources && uavResources.size() > 0) {
            List<UavResourceListInfo> uavResourceListInfos = new ArrayList<>();
            uavResources.forEach(uavResource -> {
                UavResourceListInfo uavResourceListInfo = new UavResourceListInfo();
                uavResourceListInfo.setCreateTime(StringUtils.isNotBlank(uavResource.getCreateTime()) ?
                        StringUtils.substringBefore(uavResource.getCreateTime(), AppConstant.MYBATIS_DATA_TIME_SEPARATOR) : StringUtils.EMPTY);
                uavResourceListInfo.setId(uavResource.getId());
                uavResourceListInfo.setUavName(uavResource.getUavName());
                uavResourceListInfo.setUavNumber(uavResource.getUavNumber());
                uavResourceListInfo.setUavRtsp(uavResource.getUavRtsp());
                uavResourceListInfo.setId(uavResource.getId());
                uavResourceListInfos.add(uavResourceListInfo);
            });
            return uavResourceListInfos;
        }
        return new ArrayList<>();
    }


}
